package cn.com.yusys.yusp.admin.service;

import cn.com.yusys.yusp.admin.repository.mapper.DashBoardMapper;
import cn.com.yusys.yusp.commons.mapper.QueryModel;
import cn.com.yusys.yusp.mobile.repository.mapper.HomePageTaskMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.*;
import java.util.List;
import java.util.Map;

@Service
public class DashBoardService {
    @Resource
    private DashBoardMapper dashBoardMapper ;

    @Resource
    private HomePageTaskMapper homePageTaskMapper;

    @Value("${Doc.uploadPath}")
    private String UP_ROOT_PATH;

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getPublishedBoard(QueryModel model) {
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getPublishedBoard(model);
        PageHelper.clearPage();
        return list;
    }

    @Transactional
    public Integer updateReadFlg(Map map) {
        homePageTaskMapper.updateTaskRemindNum(map);
        return  dashBoardMapper.updateReadFlg(map);
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getCustomerBirthday(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getCustomerBirthday(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getOverdueReminder(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getOverdueReminder(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getLargeMovingAccount(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getLargeMovingAccount(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getImportantCust(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getImportantCust(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getWealthReminder(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getWealthReminder(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getWithdrawalInAdvance(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getWithdrawalInAdvance(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getProductExpiration(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getProductExpiration(model);
        return list;
    }
    @Transactional(readOnly = true)
    public List<Map<String, Object>> getRepaymentReminder(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getRepaymentReminder(model);
        return list;
    }

    @Transactional(readOnly = true)
    public Map<String, Object> getRemindInfo(QueryModel model) {
        Map<String, Object> map = null;
        map = dashBoardMapper.getRemindInfo(model);
        return map;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getCustAssetDistr(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getCustAssetDistr(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getCustAssetDistrDetail(QueryModel model) {
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getCustAssetDistrDetail(model);
        PageHelper.clearPage();
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getPublishedNotice(QueryModel model) {
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getPublishedNotice(model);
        PageHelper.clearPage();
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getGridMainData(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getGridMainData(model);
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getEachGridData(QueryModel model) {
        PageHelper.startPage(model.getPage(), model.getSize());
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getEachGridData(model);
        PageHelper.clearPage();
        return list;
    }

    @Transactional(readOnly = true)
    public List<Map<String, Object>> getRedBlackList(QueryModel model) {
        List<Map<String, Object>> list = null;
        list = dashBoardMapper.getRedBlackList(model);
        return list;
    }

}
